package srzy

import org.junit.Assert._
import org.junit.Test
import srzy.diameter._
import srzy.common.packunpack._
import srzy.common.Logging
import srzy.common._
import srzy.socket._
import srzy.dao.DBUtil

class test extends Logging {

  @Test
  def test1() {
    val str = """<command name="CCA"><avp name="Session-Id" value="in.test;2000001;092603"></avp><avp name="Result-Code" value="5030"></avp><avp name="Origin-Host" value="tydic241.sm.sm_serv.chinaunicom.com"></avp><avp name="Origin-Realm" value="chinaunicom.com"></avp><avp name="Auth-Application-Id" value="4"></avp><avp name="CC-Request-Type" value="1"></avp><avp name="CC-Request-Number" value="0"></avp></command>"""
    val l = xml.XML.loadString(str)
    import srzy.diameter._
    logger.debug(l.toBytes.toDCCCompareLog)
  }

  @Test
  def test2() {
    val c = Common.readFromFile("1.xml").mkString("\n")
    val r1 = """<!--[\u0000-\uffff]*?-->""".r
    val c1 = r1.replaceAllIn(c, "")
    logger.debug(c1)
    val l1 = xml.XML.loadString(c1)
    logger.debug(l1.toFormatStr)
  }

  @Test
  def test3() {
    val rbMsgActor = RBMsgActor()
    val send = "[100=70][101=20100509090000000][001=0011199259174000000][000=ISMP001.chinatelecom.com;132020002;110][R01=18686110004][R02=18686110004][R03=13805567778][R85=1][R20=000,R201=1,R202=1][R50=000,R504=0556,R505=0556,R506=3,R507=0556,R509=1,R5012=0556][R60=000,R601=0,R602=4,R603=20100509090000,R604=20100509090030,R605=0,R606=1][B03=000,B036=6,B037=1,B038=1][B06=1][B07=1][B08=1][B21=1][B20=1]"
    logger.debug("rece:" + (rbMsgActor !! send).apply)
  }

  @Test
  def test4() {
    val rbServerMsgActor = RBServerMsgActor()
    val str = "[100=71][101=][000=ISMP001.chinatelecom.com;132020002;110][001=0011199259174000000][003=][R60=,R601=000][B03=000,B035=30100,B036=2,B037=50][B06=000,B061=60100,B062=2,B063=50,B064=3000][B07=000,B071=70100,B072=70][B08=000,B081=80100,B082=2,B083=80,B084=5000,B085=1,B086=20][B20=000,B201=,B202=,B203=,B204=][B21=000,B211=21100,B212=2,B213=100]"
    val str1 = (rbServerMsgActor !! 'getRece).apply.toString
    logger.debug("rece:" + str1)
    rbServerMsgActor ! str
    //    rbServerMsgActor !! send
    //    val send = "[100=70][101=20100509090000000][001=0011199259174000000][000=ISMP001.chinatelecom.com;132020002;110][R01=18686110004][R02=18686110004][R03=13805567778][R85=1][R20=000,R201=1,R202=1][R50=000,R504=0556,R505=0556,R506=3,R507=0556,R509=1,R5012=0556][R60=000,R601=0,R602=4,R603=20100509090000,R604=20100509090030,R605=0,R606=1][B03=000,B036=6,B037=1,B038=1][B06=1][B07=1][B08=1][B21=1][B20=1]"
    //    logger.debug("rece:" + (rbServerMsgActor !! send).apply)
  }

  //  @Test
  //  def test5() {
  //    val l = DBUtil.apply("CaseInfoSource")
  //    l.updateCaseInfo("Voice_1.1.01.xml", "wlan", "aaa", "bbb", "ccc", "ddd")
  //    println(l.getCaseInfo)
  //  }

  @Test
  def test6() {

  }

}
